package com.nuanshui.heatedloan.credit.pay;

import com.aipg.common.AipgRsp;

public enum AllinPayResultCode {

    PAY_PROCESS_SUCCESS("0000","处理成功"),
    PAY_REQUEST_ERROR("1000","报文内容检查错或者处理错（具体内容见返回错误信息）"),
    PAY_PROCESS_SYSTEM("2000","系统正在对数据处理 中间状态"),
    PAY_PROCESS_AUDIT("2001","等待商户审核中间状态"),
    PAY_PROCESS_WAIT("2003","等待 受理中间状态"),
    PAY_PROCESS_REAUDIT("2005","等待 复核中间状态"),
    PAY_PROCESS_BANK("2007","提交银行处理中间状态"),
    PAY_PROCESS_TIMEOUT("2008","实时交易超时(中间状态,需要查询)"),
    PAY_NO_BANK_CHANNEL("3066","银行渠道不支持");


    private String code;
    private String desc; //文本内容描述

    private AllinPayResultCode(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return this.code;
    }

    public String getDesc() {
        return desc;
    }

    public static boolean isBankChannelNotSupport(AipgRsp aipgRsp)
    {
        return PAY_NO_BANK_CHANNEL.getCode().equals(aipgRsp.getINFO().getRET_CODE());
    }

    public static boolean isSuccess(AipgRsp aipgRsp)
    {
        return isSuccess(aipgRsp.getINFO().getRET_CODE());
    }

    public static boolean isSuccess(String code)
    {
        return PAY_PROCESS_SUCCESS.getCode().equals(code);
    }

    /**
     * 中间态
     * @param code
     * @return
     */
    public static boolean isMiddleCode(String code)
    {
        return  (PAY_PROCESS_SYSTEM.getCode().equals(code) ||
                PAY_PROCESS_AUDIT.getCode().equals(code) ||
                PAY_PROCESS_WAIT.getCode().equals(code) ||
                PAY_PROCESS_REAUDIT.getCode().equals(code) ||
                PAY_PROCESS_BANK.getCode().equals(code) ||
                PAY_PROCESS_TIMEOUT.getCode().equals(code));
    }
}
